<?php
class ForumPost extends ForumsAppModel
{
 var $name = 'ForumPost';
 var $belongsTo = array('ForumThread' => array('className' => 'Forums.ForumThread'), 'User' => array('fields' => array("id", "username", "avatar", "signature")));
 var $actsAs = array('Tag'=>array('table_label'=>'tags', 'tags_label'=>'tag', 'separator'=>','), 'Sluggable');
 var $hasMany = array('ForumUnread' => array (
 							'className' => 'Forums.ForumUnread',
 							'dependent' => true
 						));

 var $hasAndBelongsToMany = "Tag";

 function afterSave($created = false)
 {
 	if ($created)
 	{
 		$data['ForumUnread']['user_id'] = $this->data['ForumPost']['user_id'];
 		$data['ForumUnread']['forum_thread_id'] = $this->data['ForumPost']['forum_thread_id'];
 		$data['ForumUnread']['forum_post_id'] = $this->id;

 		$this->ForumUnread->deleteAll(array('ForumUnread.forum_thread_id' => $this->data['ForumPost']['forum_thread_id'], 'ForumUnread.user_id' => $this->data['ForumPost']['user_id']));
 		$this->ForumUnread->save($data);
 	}
 }
}
?>